<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/27 0027
 * Time: 16:42
 */

namespace app\api\controller\v1;
use app\api\model\Theme as ThemeModel;
use app\common\lib\exception\ApiException;


class Theme
{
    /**
     * @param $ids
     * @return array
     * @throws ApiException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getSimpleList($ids)
    {
        $ids = explode(',',$ids);
        $result = ThemeModel::with(['topicImg', 'headImg'])->select($ids);
        if ($result) {
            return show(200, '', $result);
        }else{
            throw new ApiException('数据不存在', '500', '401');
        }
    }

    public function getComplexOne($id)
    {
        $result = ThemeModel::getThemeWithProducts($id);
        if ($result) {
            return show(200, '', $result);
        }else{
            throw new ApiException('数据不存在', '500', '401');
        }
    }


}